package com.example.demo.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.demo.bo.StudentsPageBO;
import com.example.demo.entity.Students;
import com.example.demo.service.IStudentsService;
import com.example.demo.service.impl.StudentsServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author author
 * @since 2022-10-15
 */
@RestController
@RequestMapping("/students")
@Api("学生模块")
@Slf4j
public class StudentsController {

    @Autowired
    private IStudentsService iStudentsService;

    @GetMapping(value = "/{id}")
    @ApiOperation(value = "查询id")
    public Students findHealthPage(@PathVariable String id) {
        log.info("查询");
        return iStudentsService.getById(id);
    }

    @PostMapping(value = "page")
    @ApiOperation(value = "分页")
    public Page<Students> findHealthPage(@RequestBody StudentsPageBO studentsPageBO) {

        log.info("分页查询");

        return iStudentsService.pages(studentsPageBO);
    }
}
